#include <bits/stdc++.h>
#define It std::set<ODT>::iterator

typedef long long ll;

struct ODT {
    ll l, r;
    ll val;
    ODT(ll _l = 0, ll _r = 0, ll _val = 0):l(_l), r(_r), val(_val) {return;}
    bool operator < (const ODT &x) {
        return l < x.l;
    }
};
std::set<ODT> tree;

It split(ll x) { // 分裂区间，返回左端点为 x 的节点
    It it = tree.lower_bound(ODT(x));
    if (it != tree.end() && it->l == x) return it;
    it--; ll l = it->l, r = it->r, val = it->val;
    tree.erase(it); tree.insert(ODT(l, x - 1, val));
    return tree.insert(ODT(x, r, val)).first;
}

void assign(ll l, ll r, ll val) { // 区间推平，将 [l, r] 赋值为 val
    It itr = split(r + 1), itl = split(l);
    tree.erase(itl, itr); tree.insert(ODT(l, r, val));
    return;
}